package com.example.project.controller.project;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.project.annotation.Log;
import com.example.project.core.controller.BaseController;
import com.example.project.core.domain.AjaxResult;
import com.example.project.core.page.TableDataInfo;
import com.example.project.entity.IssuePrioritie;
import com.example.project.enums.BusinessType;
import com.example.project.service.IssuePrioritieService;
import com.example.project.utils.poi.ExcelUtil;

/**
 * 需求优先级Controller
 * 
 * @author ruoyi
 * @date 2025-10-28
 */
@Controller
@RequestMapping("/project/prioritie")
public class IssuePrioritieController extends BaseController {
	
	private String prefix = "pm/prioritie";

	@Autowired
	private IssuePrioritieService issuiPrioritieService;

	@RequiresPermissions("project:prioritie:view")
	@GetMapping()
	public String priorities() {
		return prefix + "/prioritie";
	}

	/**
	 * 查询需求优先级列表
	 */
	@RequiresPermissions("project:prioritie:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(IssuePrioritie issuePrioritie) {
		startPage();
		List<IssuePrioritie> list = issuiPrioritieService.selectIssuePrioritieList(issuePrioritie);
		return getDataTable(list);
	}

	/**
	 * 导出需求优先级列表
	 */
	@RequiresPermissions("project:prioritie:export")
	@Log(title = "需求优先级", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(IssuePrioritie issuePrioritie) {
		List<IssuePrioritie> list = issuiPrioritieService.selectIssuePrioritieList(issuePrioritie);
		ExcelUtil<IssuePrioritie> util = new ExcelUtil<IssuePrioritie>(IssuePrioritie.class);
		return util.exportExcel(list, "需求优先级数据");
	}

	/**
	 * 新增需求优先级
	 */
	@RequiresPermissions("project:prioritie:add")
	@GetMapping("/add")
	public String add() {
		return prefix + "/add";
	}

	/**
	 * 新增保存需求优先级
	 */
	@RequiresPermissions("project:prioritie:add")
	@Log(title = "需求优先级", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(IssuePrioritie issuePrioritie) {
		return toAjax(issuiPrioritieService.insertIssuePrioritie(issuePrioritie));
	}

	/**
	 * 修改需求优先级
	 */
	@RequiresPermissions("project:prioritie:edit")
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap) {
		IssuePrioritie issuePrioritie = issuiPrioritieService.selectIssuePrioritieById(id);
		mmap.put("issuePrioritie", issuePrioritie);
		return prefix + "/edit";
	}

	/**
	 * 修改保存需求优先级
	 */
	@RequiresPermissions("project:prioritie:edit")
	@Log(title = "需求优先级", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(IssuePrioritie issuePrioritie) {
		return toAjax(issuiPrioritieService.updateIssuePrioritie(issuePrioritie));
	}

	/**
	 * 删除需求优先级
	 */
	@RequiresPermissions("project:prioritie:remove")
	@Log(title = "需求优先级", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public AjaxResult remove(String ids) {
		return toAjax(issuiPrioritieService.deleteIssuePrioritieByIds(ids));
	}
}
